<?php
namespace Home\Controller;

use Think\Controller;

class IndexController extends Controller
{
    public function login()
    {
        is_login() && $this->redirect('/home/home/index');
        $this->display();
    }

    public function logout()
    {
        session('user_auth', null);
        session('user_role', null);
        $this->redirect('/');
        //$this->display();
    }

    public function doLogin($account, $password)
    {
        $SysUser = D('SysUser');
        $flag = $SysUser->do_login($account, $password);
        if ($flag) {
            echo '1';
        } else {
            echo '0';
        }
        exit();
    }

    public function clear()
    {
        fc_clear_all();
        echo 'all clear';
        exit();
    }

    public function reset()
    {
        fc_reset_temp_statistics();
        fc_clear_all();
        echo 'all clear and temp statistics reset';
        exit();
    }

    public function test1()
    {
        $user_menu_list = session('user_menu_list');
//        p($user_menu_list);
        $path = '/custom/index/sea';
        $current_menu = fc_get_menu_by_path($user_menu_list, $path);
        echo $current_menu->get_data('name');
        p($current_menu);
        exit();
    }

    public function test2()
    {
        $departs = fc_get_department_tree();
//        ($departs);
        echo json_encode($departs);
        exit();
    }

    public function test3()
    {

//        $departs = fc_get_department_from_tree(2);
//        ($departs);
//        echo json_encode($departs);
//        fc_set_temp_statistics(5,'follow_count',1,false);
        exit();
    }
}